package com.cjm.one.config;

import com.aliyun.green20220302.Client;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.aliyun.teaopenapi.models.Config;
@Configuration
@Slf4j
@EnableConfigurationProperties(GreenPropertis.class)
public class GreenConfig {
    @Resource
    private GreenPropertis greenPropertis;

    @Bean("GreenClient")
    public Client createClient() throws Exception {
        log.info("greenPropertis:{}",greenPropertis);
         Config config = new Config();
        config.setAccessKeyId(greenPropertis.getAccessKeyId());
        config.setAccessKeySecret(greenPropertis.getAccessKeySecret());
        //接入区域和地址请根据实际情况修改
        config.setRegionId(greenPropertis.getRegionId());
        config.setEndpoint(greenPropertis.getEndpoint());
        //读取时超时时间，单位毫秒（ms）。
        config.setReadTimeout(greenPropertis.getReadTimeout());
        //连接时超时时间，单位毫秒（ms）。
        config.setConnectTimeout(greenPropertis.getConnectTimeout());
        Client client = new Client(config);

        return client;
    }
}
